<template>
  <div class="divBox">
    <el-card class="box-card">
      <el-table
        v-loading="listLoading"
        :data="tableData.data"
        style="width: 100%"
        size="mini"
        ref="multipleTable"
        :header-cell-style="{ fontWeight: 'bold' }"
      >
        <el-table-column prop="id" label="头像" min-width="80">
          <template slot-scope="scope">
            <div class="demo-image__preview">
              <el-image
                :src="scope.row.avatar"
                :preview-src-list="[scope.row.videoUrl]"
              />
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="title" label="姓名" min-width="150" />
        <el-table-column prop="startDate" label="下发时间" min-width="150" />
        <el-table-column prop="compDate" label="用户确认时间" min-width="150" />
        <el-table-column
          prop="compDate"
          label="最后一次登录时间"
          min-width="150"
        />
      </el-table>
      <div class="block mb20">
        <el-pagination
          :page-sizes="[10, 20, 30, 40]"
          :page-size="tableFrom.limit"
          :current-page="tableFrom.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="pageChange"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import {
  bargainListApi,
  bargainOrderPinkApi,
  bargainDeleteApi,
} from "@/api/marketing";
import * as categoryApi from "@/api/categoryApi.js";
export default {
  name: "index",
  data() {
    return {
      categoryTreeData: [],
      tableData: {
        data: [],
        total: 0,
      },
      listLoading: false,
      chooseUser: false,
      tableFrom: {
        dateLimit: "",
        status: "",
        page: 1,
        limit: 20,
        cid: "",
        keywords: "",
      },
      fromList: this.$constants.fromList,
      timeVal: [],
    };
  },
  mounted() {
    this.getList();
    this.handlerGetTreeList();
  },
  methods: {
    //日日练推送记录
    record(id) {},

    //推送至人员
    sendUser(id) {
      this.chooseUser = true;
      this.$nextTick(() => {
        this.$refs.choose.modalPicTap(id);
      });
    },

    //删除日日练
    deletekLook(id) {
      bargainDeleteApi({ id: id }).then(() => {
        that.$message.success("删除成功");
        that.getList();
      });
    },

    handerSearch() {
      this.getList();
    },

    handlerGetTreeList() {
      categoryApi
        .listCategroy({
          type: 3,
          status: "",
        })
        .then((data) => {
          this.categoryTreeData = data.list;
          localStorage.setItem("articleClass", JSON.stringify(data.list));
        });
    },

    selectChange(tab) {
      this.tableFrom.dateLimit = tab;
      this.tableFrom.page = 1;
      this.timeVal = [];
      this.getList();
    },
    // 具体日期
    onchangeTime(e) {
      this.timeVal = e;
      this.tableFrom.dateLimit = e ? this.timeVal.join(",") : "";
      this.tableFrom.page = 1;
      this.getList();
    },
    // 列表
    getList(num) {
      this.listLoading = true;
      this.tableFrom.page = num ? num : this.tableFrom.page;
      bargainListApi(this.tableFrom)
        .then((res) => {
          this.tableData.data = res.list;
          this.tableData.total = res.total;
          this.listLoading = false;
        })
        .catch(() => {
          this.listLoading = false;
        });
    },
    pageChange(page) {
      this.tableFrom.page = page;
      this.getList();
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val;
      this.getList();
    },
  },
};
</script>

<style scoped>
.el-table__body {
  width: 100%;
  table-layout: fixed !important;
}

.text_overflow {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.pup_card {
  width: 200px;
  border-radius: 5px;
  padding: 5px;
  box-sizing: border-box;
  font-size: 12px;
  line-height: 16px;
}
</style>
